package com.minimalist.basic.controller.lindi;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.subsidyapplicationpaynotice.LindiSubsidyApplicationPayNoticeQueryVO;
import com.minimalist.common.entity.lindi.vo.subsidyapplicationpaynotice.LindiSubsidyApplicationPayNoticeVO;
import com.minimalist.common.feign.client.lindi.LindiSubsidyApplicationPayNoticeFeignClient;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 林地指标交易平台_补贴申请支付通知控制器
 *
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标交易平台_补贴申请支付通知管理")
@RequestMapping("/basic/lindi/subsidyApplicationPayNotice")
public class LindiSubsidyApplicationPayNoticeController{

    @Autowired
    private LindiSubsidyApplicationPayNoticeFeignClient feignClient;

    @PostMapping("/addSubsidyApplicationPayNotice")
    @Operation(summary = "添加补贴申请支付通知")
    @SaCheckPermission("lindi:subsidyApplicationPayNotice:add")
    public R<?> addSubsidyApplicationPayNotice(
            @RequestBody @Validated(Add.class) LindiSubsidyApplicationPayNoticeVO
                    subsidyApplicationPayNoticeVO){
        subsidyApplicationPayNoticeVO.setCreateId(StpUtil.getLoginIdAsLong());
        subsidyApplicationPayNoticeVO.setUpdateId(StpUtil.getLoginIdAsLong());
        LocalDateTime now = LocalDateTime.now();
        subsidyApplicationPayNoticeVO.setCreateTime(now);
        subsidyApplicationPayNoticeVO.setUpdateTime(now);
        return feignClient.addSubsidyApplicationPayNotice(subsidyApplicationPayNoticeVO);
    }

    @DeleteMapping("/deleteSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId")
    @Operation(summary = "删除补贴申请支付通知 -> 根据补贴申请支付通知ID删除")
    @SaCheckPermission("lindi:subsidyApplicationPayNotice:delete")
    public R<?> deleteSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId(
            @RequestParam("subsidyApplicationPayNoticeId")
            @NotNull(message = "补贴申请支付通知ID不能为空")
            @Parameter(name = "subsidyApplicationPayNoticeId", required = true, description = "补贴申请支付通知ID")
            Long subsidyApplicationPayNoticeId){
        return feignClient.deleteSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId(
                subsidyApplicationPayNoticeId);
    }

    @PutMapping("/updateSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId")
    @Operation(summary = "修改补贴申请支付通知")
    @SaCheckPermission("lindi:subsidyApplicationPayNotice:update")
    public R<?> updateSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId(
            @RequestBody @Validated(Update.class) LindiSubsidyApplicationPayNoticeVO
                    subsidyApplicationPayNoticeVO){
        subsidyApplicationPayNoticeVO.setUpdateId(StpUtil.getLoginIdAsLong());
        LocalDateTime now = LocalDateTime.now();
        subsidyApplicationPayNoticeVO.setUpdateTime(now);
        return feignClient.updateSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId(
                subsidyApplicationPayNoticeVO);
    }

    @GetMapping("/getPageSubsidyApplicationPayNoticeList")
    @Operation(summary = "查询补贴申请支付通知列表(分页)")
    @SaCheckPermission("lindi:subsidyApplicationPayNotice:get")
    public R<PageResp<LindiSubsidyApplicationPayNoticeVO>> getPageSubsidyApplicationPayNoticeList(
            LindiSubsidyApplicationPayNoticeQueryVO queryVO){
        return feignClient.getPageSubsidyApplicationPayNoticeList(queryVO);
    }

    @GetMapping("/getSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId/{subsidyApplicationPayNoticeId}")
    @Operation(summary = "根据补贴申请支付通知ID查询补贴申请支付通知")
    @SaCheckPermission("lindi:subsidyApplicationPayNotice:get")
    public R<LindiSubsidyApplicationPayNoticeVO>
    getSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId(
            @PathVariable(value = "subsidyApplicationPayNoticeId")
            @NotNull(message = "补贴申请支付通知ID不能为空")
            @Parameter(name = "subsidyApplicationPayNoticeId", description = "补贴申请支付通知ID", required = true)
            Long subsidyApplicationPayNoticeId){
        return feignClient.getSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId
                (subsidyApplicationPayNoticeId);
    }

    @GetMapping("/getSubsidyApplicationPayNoticeListBySubsidyApplicationId/{subsidyApplicationId}")
    @Operation(summary = "根据补贴申请ID查询支付通知列表")
    @SaCheckPermission("lindi:subsidyApplicationPayNotice:get")
    public R<List<LindiSubsidyApplicationPayNoticeVO>> getSubsidyApplicationPayNoticeListBySubsidyApplicationId(
            @PathVariable(value = "subsidyApplicationId")
            @NotNull(message = "补贴申请ID不能为空")
            @Parameter(name = "subsidyApplicationId", description = "补贴申请ID", required = true)
            Long subsidyApplicationId){
        return feignClient.getSubsidyApplicationPayNoticeListBySubsidyApplicationId(subsidyApplicationId);
    }
}